[Console] Preserve spaces in URL query strings#270881
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Preserves unquoted spaces inside Console request URL query values so request-lines like ...q=foo AND bar aren’t truncated, while still stripping trailing inline // and # comments.
Changes:
- Updates
removeTrailingWhitespacesto treat spaces differently once the URL has entered the query string. - Keeps inline-comment stripping behavior (
//and#) when whitespace begins an inline comment. - Adds Jest coverage for the reported bug case and the
parseLinerequest-line path.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/platform/plugins/shared/console/public/application/containers/editor/utils/tokens_utils.ts |
Adjusts URL whitespace stripping to preserve query-value spaces while still recognizing inline comments. |
src/platform/plugins/shared/console/public/application/containers/editor/utils/tokens_utils.test.ts |
Adds tests covering unquoted query spaces and the request-line parsing path. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
6d5ff4d to
427bb46
Compare
|
Pinging @elastic/kibana-management (Team:Kibana Management) |
427bb46 to
54ac103
Compare
There was a problem hiding this comment.
Review complete. I left one inline comment about the quoted-question-mark case still mis-tokenizing through parseLine/parseUrl, which affects autocomplete context even though the URL string is now preserved.
Generated by Codex Reviewer for issue #270881
54ac103 to
6388bb8
Compare
SoniaSanzV
left a comment
There was a problem hiding this comment.
tested locally, lgtm!
65a4223 to
6e2cc4f
Compare
Co-authored-by: Cursor <cursoragent@cursor.com>
6e2cc4f to
9b383ab
Compare
There was a problem hiding this comment.
Found one remaining autocomplete consistency issue for quoted question marks in URL paths.
Generated by Codex Reviewer for issue #270881
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Async chunks
History
|
|
Starting backport for target branches: 8.19, 9.3, 9.4 |
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
# Backport This will backport the following commits from `main` to `9.4`: - [[Console] Preserve spaces in URL query strings (#270881)](#270881) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Karen Grigoryan","email":"karen.grigoryan@elastic.co"},"sourceCommit":{"committedDate":"2026-05-26T08:17:39Z","message":"[Console] Preserve spaces in URL query strings (#270881)\n\nCloses #227733\n\n## Summary\n\n- Preserves unquoted spaces in Console URL query values instead of\ntreating them as request-line trailing text.\n- Keeps inline `//` and `#` comment stripping for request URLs.\n- Adds focused edge-case coverage for the helper and the full\n`parseLine` request-line path.\n\n## Root Cause\n\n- `removeTrailingWhitespaces` stopped at the first unquoted space, so\n`GET myindex/_search?q=type:organisation AND elastic` was truncated\nbefore `AND elastic`.\n\n## Fix\n\n- Use the first `?` outside quotes as the query-string boundary.\n- Preserve spaces inside query values unless the space starts a trailing\ninline `//` or `#` comment.\n- Preserve the existing leading-space behavior and ignore comment\nmarkers inside quoted query values.\n\n## Before\n<img width=\"1494\" height=\"1313\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/5ff9ebfe-dc42-4904-a87d-976dbadc2823\"\n/>\n\n## After\n<img width=\"1482\" height=\"1365\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/cf4bb6b3-56cf-4a39-9932-5d69f2a3cb95\"\n/>\n\n## Test Plan\n\n- [x] `node scripts/jest\nsrc/platform/plugins/shared/console/public/application/containers/editor/utils/tokens_utils.test.ts`\n- [x] `node scripts/eslint\nsrc/platform/plugins/shared/console/public/application/containers/editor/utils/tokens_utils.ts\nsrc/platform/plugins/shared/console/public/application/containers/editor/utils/tokens_utils.test.ts`\n- [x] `node scripts/type_check --project\nsrc/platform/plugins/shared/console/tsconfig.json`\n- [x] `node scripts/check_changes.ts`\n- [x] Manually verified in Console that unquoted query spaces are\npreserved, trailing `//` and `#` comments are stripped, comment markers\ninside quoted query values are preserved, quoted `?` path text is not\ntreated as the query delimiter, and trailing non-query text is trimmed\nbefore sending the request.\n\nAssisted with Cursor using GPT-5.5\n\nCo-authored-by: Cursor <cursoragent@cursor.com>","sha":"9d7d16103bc774badc83cba0622e7c4fc602e977","branchLabelMapping":{"^v9.5.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Console","Team:Kibana Management","release_note:skip","backport:all-open","reviewer:claude","v9.5.0","reviewer:codex"],"title":"[Console] Preserve spaces in URL query strings","number":270881,"url":"https://github.com/elastic/kibana/pull/270881","mergeCommit":{"message":"[Console] Preserve spaces in URL query strings (#270881)\n\nCloses #227733\n\n## Summary\n\n- Preserves unquoted spaces in Console URL query values instead of\ntreating them as request-line trailing text.\n- Keeps inline `//` and `#` comment stripping for request URLs.\n- Adds focused edge-case coverage for the helper and the full\n`parseLine` request-line path.\n\n## Root Cause\n\n- `removeTrailingWhitespaces` stopped at the first unquoted space, so\n`GET myindex/_search?q=type:organisation AND elastic` was truncated\nbefore `AND elastic`.\n\n## Fix\n\n- Use the first `?` outside quotes as the query-string boundary.\n- Preserve spaces inside query values unless the space starts a trailing\ninline `//` or `#` comment.\n- Preserve the existing leading-space behavior and ignore comment\nmarkers inside quoted query values.\n\n## Before\n<img width=\"1494\" height=\"1313\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/5ff9ebfe-dc42-4904-a87d-976dbadc2823\"\n/>\n\n## After\n<img width=\"1482\" height=\"1365\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/cf4bb6b3-56cf-4a39-9932-5d69f2a3cb95\"\n/>\n\n## Test Plan\n\n- [x] `node scripts/jest\nsrc/platform/plugins/shared/console/public/application/containers/editor/utils/tokens_utils.test.ts`\n- [x] `node scripts/eslint\nsrc/platform/plugins/shared/console/public/application/containers/editor/utils/tokens_utils.ts\nsrc/platform/plugins/shared/console/public/application/containers/editor/utils/tokens_utils.test.ts`\n- [x] `node scripts/type_check --project\nsrc/platform/plugins/shared/console/tsconfig.json`\n- [x] `node scripts/check_changes.ts`\n- [x] Manually verified in Console that unquoted query spaces are\npreserved, trailing `//` and `#` comments are stripped, comment markers\ninside quoted query values are preserved, quoted `?` path text is not\ntreated as the query delimiter, and trailing non-query text is trimmed\nbefore sending the request.\n\nAssisted with Cursor using GPT-5.5\n\nCo-authored-by: Cursor <cursoragent@cursor.com>","sha":"9d7d16103bc774badc83cba0622e7c4fc602e977"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.5.0","branchLabelMappingKey":"^v9.5.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/270881","number":270881,"mergeCommit":{"message":"[Console] Preserve spaces in URL query strings (#270881)\n\nCloses #227733\n\n## Summary\n\n- Preserves unquoted spaces in Console URL query values instead of\ntreating them as request-line trailing text.\n- Keeps inline `//` and `#` comment stripping for request URLs.\n- Adds focused edge-case coverage for the helper and the full\n`parseLine` request-line path.\n\n## Root Cause\n\n- `removeTrailingWhitespaces` stopped at the first unquoted space, so\n`GET myindex/_search?q=type:organisation AND elastic` was truncated\nbefore `AND elastic`.\n\n## Fix\n\n- Use the first `?` outside quotes as the query-string boundary.\n- Preserve spaces inside query values unless the space starts a trailing\ninline `//` or `#` comment.\n- Preserve the existing leading-space behavior and ignore comment\nmarkers inside quoted query values.\n\n## Before\n<img width=\"1494\" height=\"1313\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/5ff9ebfe-dc42-4904-a87d-976dbadc2823\"\n/>\n\n## After\n<img width=\"1482\" height=\"1365\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/cf4bb6b3-56cf-4a39-9932-5d69f2a3cb95\"\n/>\n\n## Test Plan\n\n- [x] `node scripts/jest\nsrc/platform/plugins/shared/console/public/application/containers/editor/utils/tokens_utils.test.ts`\n- [x] `node scripts/eslint\nsrc/platform/plugins/shared/console/public/application/containers/editor/utils/tokens_utils.ts\nsrc/platform/plugins/shared/console/public/application/containers/editor/utils/tokens_utils.test.ts`\n- [x] `node scripts/type_check --project\nsrc/platform/plugins/shared/console/tsconfig.json`\n- [x] `node scripts/check_changes.ts`\n- [x] Manually verified in Console that unquoted query spaces are\npreserved, trailing `//` and `#` comments are stripped, comment markers\ninside quoted query values are preserved, quoted `?` path text is not\ntreated as the query delimiter, and trailing non-query text is trimmed\nbefore sending the request.\n\nAssisted with Cursor using GPT-5.5\n\nCo-authored-by: Cursor <cursoragent@cursor.com>","sha":"9d7d16103bc774badc83cba0622e7c4fc602e977"}}]}] BACKPORT--> Co-authored-by: Karen Grigoryan <karen.grigoryan@elastic.co> Co-authored-by: Cursor <cursoragent@cursor.com>
) # Backport This will backport the following commits from `main` to `8.19`: - [[Console] Preserve spaces in URL query strings (#270881)](#270881) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Karen Grigoryan","email":"karen.grigoryan@elastic.co"},"sourceCommit":{"committedDate":"2026-05-26T08:17:39Z","message":"[Console] Preserve spaces in URL query strings (#270881)\n\nCloses #227733\n\n## Summary\n\n- Preserves unquoted spaces in Console URL query values instead of\ntreating them as request-line trailing text.\n- Keeps inline `//` and `#` comment stripping for request URLs.\n- Adds focused edge-case coverage for the helper and the full\n`parseLine` request-line path.\n\n## Root Cause\n\n- `removeTrailingWhitespaces` stopped at the first unquoted space, so\n`GET myindex/_search?q=type:organisation AND elastic` was truncated\nbefore `AND elastic`.\n\n## Fix\n\n- Use the first `?` outside quotes as the query-string boundary.\n- Preserve spaces inside query values unless the space starts a trailing\ninline `//` or `#` comment.\n- Preserve the existing leading-space behavior and ignore comment\nmarkers inside quoted query values.\n\n## Before\n<img width=\"1494\" height=\"1313\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/5ff9ebfe-dc42-4904-a87d-976dbadc2823\"\n/>\n\n## After\n<img width=\"1482\" height=\"1365\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/cf4bb6b3-56cf-4a39-9932-5d69f2a3cb95\"\n/>\n\n## Test Plan\n\n- [x] `node scripts/jest\nsrc/platform/plugins/shared/console/public/application/containers/editor/utils/tokens_utils.test.ts`\n- [x] `node scripts/eslint\nsrc/platform/plugins/shared/console/public/application/containers/editor/utils/tokens_utils.ts\nsrc/platform/plugins/shared/console/public/application/containers/editor/utils/tokens_utils.test.ts`\n- [x] `node scripts/type_check --project\nsrc/platform/plugins/shared/console/tsconfig.json`\n- [x] `node scripts/check_changes.ts`\n- [x] Manually verified in Console that unquoted query spaces are\npreserved, trailing `//` and `#` comments are stripped, comment markers\ninside quoted query values are preserved, quoted `?` path text is not\ntreated as the query delimiter, and trailing non-query text is trimmed\nbefore sending the request.\n\nAssisted with Cursor using GPT-5.5\n\nCo-authored-by: Cursor <cursoragent@cursor.com>","sha":"9d7d16103bc774badc83cba0622e7c4fc602e977","branchLabelMapping":{"^v9.5.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Console","Team:Kibana Management","release_note:skip","backport:all-open","reviewer:claude","v9.5.0","reviewer:codex"],"title":"[Console] Preserve spaces in URL query strings","number":270881,"url":"https://github.com/elastic/kibana/pull/270881","mergeCommit":{"message":"[Console] Preserve spaces in URL query strings (#270881)\n\nCloses #227733\n\n## Summary\n\n- Preserves unquoted spaces in Console URL query values instead of\ntreating them as request-line trailing text.\n- Keeps inline `//` and `#` comment stripping for request URLs.\n- Adds focused edge-case coverage for the helper and the full\n`parseLine` request-line path.\n\n## Root Cause\n\n- `removeTrailingWhitespaces` stopped at the first unquoted space, so\n`GET myindex/_search?q=type:organisation AND elastic` was truncated\nbefore `AND elastic`.\n\n## Fix\n\n- Use the first `?` outside quotes as the query-string boundary.\n- Preserve spaces inside query values unless the space starts a trailing\ninline `//` or `#` comment.\n- Preserve the existing leading-space behavior and ignore comment\nmarkers inside quoted query values.\n\n## Before\n<img width=\"1494\" height=\"1313\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/5ff9ebfe-dc42-4904-a87d-976dbadc2823\"\n/>\n\n## After\n<img width=\"1482\" height=\"1365\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/cf4bb6b3-56cf-4a39-9932-5d69f2a3cb95\"\n/>\n\n## Test Plan\n\n- [x] `node scripts/jest\nsrc/platform/plugins/shared/console/public/application/containers/editor/utils/tokens_utils.test.ts`\n- [x] `node scripts/eslint\nsrc/platform/plugins/shared/console/public/application/containers/editor/utils/tokens_utils.ts\nsrc/platform/plugins/shared/console/public/application/containers/editor/utils/tokens_utils.test.ts`\n- [x] `node scripts/type_check --project\nsrc/platform/plugins/shared/console/tsconfig.json`\n- [x] `node scripts/check_changes.ts`\n- [x] Manually verified in Console that unquoted query spaces are\npreserved, trailing `//` and `#` comments are stripped, comment markers\ninside quoted query values are preserved, quoted `?` path text is not\ntreated as the query delimiter, and trailing non-query text is trimmed\nbefore sending the request.\n\nAssisted with Cursor using GPT-5.5\n\nCo-authored-by: Cursor <cursoragent@cursor.com>","sha":"9d7d16103bc774badc83cba0622e7c4fc602e977"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.5.0","branchLabelMappingKey":"^v9.5.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/270881","number":270881,"mergeCommit":{"message":"[Console] Preserve spaces in URL query strings (#270881)\n\nCloses #227733\n\n## Summary\n\n- Preserves unquoted spaces in Console URL query values instead of\ntreating them as request-line trailing text.\n- Keeps inline `//` and `#` comment stripping for request URLs.\n- Adds focused edge-case coverage for the helper and the full\n`parseLine` request-line path.\n\n## Root Cause\n\n- `removeTrailingWhitespaces` stopped at the first unquoted space, so\n`GET myindex/_search?q=type:organisation AND elastic` was truncated\nbefore `AND elastic`.\n\n## Fix\n\n- Use the first `?` outside quotes as the query-string boundary.\n- Preserve spaces inside query values unless the space starts a trailing\ninline `//` or `#` comment.\n- Preserve the existing leading-space behavior and ignore comment\nmarkers inside quoted query values.\n\n## Before\n<img width=\"1494\" height=\"1313\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/5ff9ebfe-dc42-4904-a87d-976dbadc2823\"\n/>\n\n## After\n<img width=\"1482\" height=\"1365\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/cf4bb6b3-56cf-4a39-9932-5d69f2a3cb95\"\n/>\n\n## Test Plan\n\n- [x] `node scripts/jest\nsrc/platform/plugins/shared/console/public/application/containers/editor/utils/tokens_utils.test.ts`\n- [x] `node scripts/eslint\nsrc/platform/plugins/shared/console/public/application/containers/editor/utils/tokens_utils.ts\nsrc/platform/plugins/shared/console/public/application/containers/editor/utils/tokens_utils.test.ts`\n- [x] `node scripts/type_check --project\nsrc/platform/plugins/shared/console/tsconfig.json`\n- [x] `node scripts/check_changes.ts`\n- [x] Manually verified in Console that unquoted query spaces are\npreserved, trailing `//` and `#` comments are stripped, comment markers\ninside quoted query values are preserved, quoted `?` path text is not\ntreated as the query delimiter, and trailing non-query text is trimmed\nbefore sending the request.\n\nAssisted with Cursor using GPT-5.5\n\nCo-authored-by: Cursor <cursoragent@cursor.com>","sha":"9d7d16103bc774badc83cba0622e7c4fc602e977"}}]}] BACKPORT--> Co-authored-by: Karen Grigoryan <karen.grigoryan@elastic.co> Co-authored-by: Cursor <cursoragent@cursor.com>
# Backport This will backport the following commits from `main` to `9.3`: - [[Console] Preserve spaces in URL query strings (#270881)](#270881) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Karen Grigoryan","email":"karen.grigoryan@elastic.co"},"sourceCommit":{"committedDate":"2026-05-26T08:17:39Z","message":"[Console] Preserve spaces in URL query strings (#270881)\n\nCloses #227733\n\n## Summary\n\n- Preserves unquoted spaces in Console URL query values instead of\ntreating them as request-line trailing text.\n- Keeps inline `//` and `#` comment stripping for request URLs.\n- Adds focused edge-case coverage for the helper and the full\n`parseLine` request-line path.\n\n## Root Cause\n\n- `removeTrailingWhitespaces` stopped at the first unquoted space, so\n`GET myindex/_search?q=type:organisation AND elastic` was truncated\nbefore `AND elastic`.\n\n## Fix\n\n- Use the first `?` outside quotes as the query-string boundary.\n- Preserve spaces inside query values unless the space starts a trailing\ninline `//` or `#` comment.\n- Preserve the existing leading-space behavior and ignore comment\nmarkers inside quoted query values.\n\n## Before\n<img width=\"1494\" height=\"1313\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/5ff9ebfe-dc42-4904-a87d-976dbadc2823\"\n/>\n\n## After\n<img width=\"1482\" height=\"1365\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/cf4bb6b3-56cf-4a39-9932-5d69f2a3cb95\"\n/>\n\n## Test Plan\n\n- [x] `node scripts/jest\nsrc/platform/plugins/shared/console/public/application/containers/editor/utils/tokens_utils.test.ts`\n- [x] `node scripts/eslint\nsrc/platform/plugins/shared/console/public/application/containers/editor/utils/tokens_utils.ts\nsrc/platform/plugins/shared/console/public/application/containers/editor/utils/tokens_utils.test.ts`\n- [x] `node scripts/type_check --project\nsrc/platform/plugins/shared/console/tsconfig.json`\n- [x] `node scripts/check_changes.ts`\n- [x] Manually verified in Console that unquoted query spaces are\npreserved, trailing `//` and `#` comments are stripped, comment markers\ninside quoted query values are preserved, quoted `?` path text is not\ntreated as the query delimiter, and trailing non-query text is trimmed\nbefore sending the request.\n\nAssisted with Cursor using GPT-5.5\n\nCo-authored-by: Cursor <cursoragent@cursor.com>","sha":"9d7d16103bc774badc83cba0622e7c4fc602e977","branchLabelMapping":{"^v9.5.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Console","Team:Kibana Management","release_note:skip","backport:all-open","reviewer:claude","v9.5.0","reviewer:codex"],"title":"[Console] Preserve spaces in URL query strings","number":270881,"url":"https://github.com/elastic/kibana/pull/270881","mergeCommit":{"message":"[Console] Preserve spaces in URL query strings (#270881)\n\nCloses #227733\n\n## Summary\n\n- Preserves unquoted spaces in Console URL query values instead of\ntreating them as request-line trailing text.\n- Keeps inline `//` and `#` comment stripping for request URLs.\n- Adds focused edge-case coverage for the helper and the full\n`parseLine` request-line path.\n\n## Root Cause\n\n- `removeTrailingWhitespaces` stopped at the first unquoted space, so\n`GET myindex/_search?q=type:organisation AND elastic` was truncated\nbefore `AND elastic`.\n\n## Fix\n\n- Use the first `?` outside quotes as the query-string boundary.\n- Preserve spaces inside query values unless the space starts a trailing\ninline `//` or `#` comment.\n- Preserve the existing leading-space behavior and ignore comment\nmarkers inside quoted query values.\n\n## Before\n<img width=\"1494\" height=\"1313\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/5ff9ebfe-dc42-4904-a87d-976dbadc2823\"\n/>\n\n## After\n<img width=\"1482\" height=\"1365\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/cf4bb6b3-56cf-4a39-9932-5d69f2a3cb95\"\n/>\n\n## Test Plan\n\n- [x] `node scripts/jest\nsrc/platform/plugins/shared/console/public/application/containers/editor/utils/tokens_utils.test.ts`\n- [x] `node scripts/eslint\nsrc/platform/plugins/shared/console/public/application/containers/editor/utils/tokens_utils.ts\nsrc/platform/plugins/shared/console/public/application/containers/editor/utils/tokens_utils.test.ts`\n- [x] `node scripts/type_check --project\nsrc/platform/plugins/shared/console/tsconfig.json`\n- [x] `node scripts/check_changes.ts`\n- [x] Manually verified in Console that unquoted query spaces are\npreserved, trailing `//` and `#` comments are stripped, comment markers\ninside quoted query values are preserved, quoted `?` path text is not\ntreated as the query delimiter, and trailing non-query text is trimmed\nbefore sending the request.\n\nAssisted with Cursor using GPT-5.5\n\nCo-authored-by: Cursor <cursoragent@cursor.com>","sha":"9d7d16103bc774badc83cba0622e7c4fc602e977"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.5.0","branchLabelMappingKey":"^v9.5.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/270881","number":270881,"mergeCommit":{"message":"[Console] Preserve spaces in URL query strings (#270881)\n\nCloses #227733\n\n## Summary\n\n- Preserves unquoted spaces in Console URL query values instead of\ntreating them as request-line trailing text.\n- Keeps inline `//` and `#` comment stripping for request URLs.\n- Adds focused edge-case coverage for the helper and the full\n`parseLine` request-line path.\n\n## Root Cause\n\n- `removeTrailingWhitespaces` stopped at the first unquoted space, so\n`GET myindex/_search?q=type:organisation AND elastic` was truncated\nbefore `AND elastic`.\n\n## Fix\n\n- Use the first `?` outside quotes as the query-string boundary.\n- Preserve spaces inside query values unless the space starts a trailing\ninline `//` or `#` comment.\n- Preserve the existing leading-space behavior and ignore comment\nmarkers inside quoted query values.\n\n## Before\n<img width=\"1494\" height=\"1313\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/5ff9ebfe-dc42-4904-a87d-976dbadc2823\"\n/>\n\n## After\n<img width=\"1482\" height=\"1365\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/cf4bb6b3-56cf-4a39-9932-5d69f2a3cb95\"\n/>\n\n## Test Plan\n\n- [x] `node scripts/jest\nsrc/platform/plugins/shared/console/public/application/containers/editor/utils/tokens_utils.test.ts`\n- [x] `node scripts/eslint\nsrc/platform/plugins/shared/console/public/application/containers/editor/utils/tokens_utils.ts\nsrc/platform/plugins/shared/console/public/application/containers/editor/utils/tokens_utils.test.ts`\n- [x] `node scripts/type_check --project\nsrc/platform/plugins/shared/console/tsconfig.json`\n- [x] `node scripts/check_changes.ts`\n- [x] Manually verified in Console that unquoted query spaces are\npreserved, trailing `//` and `#` comments are stripped, comment markers\ninside quoted query values are preserved, quoted `?` path text is not\ntreated as the query delimiter, and trailing non-query text is trimmed\nbefore sending the request.\n\nAssisted with Cursor using GPT-5.5\n\nCo-authored-by: Cursor <cursoragent@cursor.com>","sha":"9d7d16103bc774badc83cba0622e7c4fc602e977"}}]}] BACKPORT--> Co-authored-by: Karen Grigoryan <karen.grigoryan@elastic.co> Co-authored-by: Cursor <cursoragent@cursor.com>
Closes #227733
Summary
//and#comment stripping for request URLs.parseLinerequest-line path.Root Cause
removeTrailingWhitespacesstopped at the first unquoted space, soGET myindex/_search?q=type:organisation AND elasticwas truncated beforeAND elastic.Fix
?outside quotes as the query-string boundary.//or#comment.Before
After
Test Plan
node scripts/jest src/platform/plugins/shared/console/public/application/containers/editor/utils/tokens_utils.test.tsnode scripts/eslint src/platform/plugins/shared/console/public/application/containers/editor/utils/tokens_utils.ts src/platform/plugins/shared/console/public/application/containers/editor/utils/tokens_utils.test.tsnode scripts/type_check --project src/platform/plugins/shared/console/tsconfig.jsonnode scripts/check_changes.ts//and#comments are stripped, comment markers inside quoted query values are preserved, quoted?path text is not treated as the query delimiter, and trailing non-query text is trimmed before sending the request.Assisted with Cursor using GPT-5.5